package com.tfleo.mealssenger.object;


public class Notice {	
	public final int type; //0 = friend request, 1 = hangout, 2 = food share
	public final String subjectName;
	public final int objectId;
	public final String objectName;
	public String message;
	
	public Notice(int type, String subjectName, int objectId, String objectName) {
		this.type = type;
		this.subjectName = subjectName;
		this.objectId = objectId;
		this.objectName = objectName;
		switch(type) {
		case 1: //friend request
			this.message = "You have pending friend request from " + subjectName;
			break;
		case 2: //share request
			this.message = composeShare(subjectName, objectName);
			break;
		case 3: //hangout
			this.message = composeHangout(subjectName, objectName);
			break;
		default:
			if(this.objectId == 0) {
				this.message = "No new notification!";
			} else {
				this.message = "You've got " + this.objectName + " new notification!";
			}
		}
	}
	
	private String composeShare(String subject, String object) {
		String composition;
		String[] compSubject;
		compSubject = subject.split(",");
		if(compSubject.length > 3) {
			composition = compSubject[0] + ", " + compSubject[1] + ", " + compSubject[2] +
					" and " + (compSubject.length - 3) + " other friends shared " + object;
		} else {
			composition = subject + " shared " + object;
		}
		return composition;
	}
	
	private String composeHangout(String subject, String object) {
		String composition;
		composition = subject + " invites you to hangout at " + object;
		return composition;
	}
	
}
